//
//  UIScrollView+Refresher.swift
//  AG
//
//  Created by zhuxuhong on 2020/10/17.
//  Copyright © 2020 AgoCulture. All rights reserved.
//


import MJRefresh
import BWToolKit

extension UIScrollView {
    public func mj_refresher(header: BlockVoid? = nil, footer: BlockVoid? = nil) {
        mj_header = (header != nil) ? MJRefreshNormalHeader(refreshingBlock: header!) : nil
        mj_footer = (footer != nil) ? MJRefreshBackNormalFooter(refreshingBlock: footer!) : nil
    }
    
    public func mj_startRefreshingHeader(_ header: Bool? = true, footer: Bool? = false) {
        if header != nil && header! {
            mj_header?.beginRefreshing()
        }
        if footer != nil && footer! {
            mj_footer?.beginRefreshing()
        }
    }
    
    public func mj_stopRefreshing(header: Bool? = true, footer: Bool? = true) {
        if header != nil && header! {
            mj_header?.endRefreshing()
        }
        if footer != nil && footer! {
            mj_footer?.endRefreshing()
        }
    }
    
    public func mj_footerNoMoreData() {
        mj_footer?.endRefreshingWithNoMoreData()
    }
}
